#include "function.h"

//--------------------------------------limit
uint8 Limit_uint8(uint8 a, uint8 b, uint8 c)
{
	if((b>=a)&&(b<=c))
	{
		return b;
	}
	else if(b<a)
	{
		return a;	
	}
	else if(b>c)
	{
		return c;
	}
	return 0;
}

uint8 Limit_int(int a, int b, int c)
{
	if((b>=a)&&(b<=c))
	{
		return b;
	}
	else if(b<a)
	{
		return a;	
	}
	else if(b>c)
	{
		return c;
	}
	return 0;
}

//---------------------------draw
void draw_line(void)
{
	for(uint8 i= MT9V03X_H-1;i>search_end_line;i--)
	{
		tft180_draw_point(0.68*Limit_int(1,left_line_list[i],MT9V03X_W-2),0.68*i,RGB565_BLUE);
		tft180_draw_point(0.68*Limit_int(1,right_line_list[i],MT9V03X_W-2),0.68*i,RGB565_GREEN);
  	tft180_draw_point(0.68*Limit_int(1,mid_line_list[i],MT9V03X_W-2),0.68*i,RGB565_RED);
	}
}




//-----------------------------init

void init(void)
{
	 tft180_init();
	 mt9v03x_init();
	 motor_Init();
	 Encoder_Init();
	 pit_ms_init(PIT_CH0,20);
   pit_ms_init(PIT_CH1,5);


}

